<%--
  User: Albert
--%>
<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>用户注册</title>
</head>
<body>

<div id="content">
    <h1>注册</h1>
    <%-- 从地址栏提取错误信息，打印到页面上 --%>
    <c:if test="${param.msg}">
        <div style="color: orangered; text-align: center; margin-bottom: 10px">
                ${param.msg}
        </div>
    </c:if>
    <%-- POST请求调用后端接口 - 用户注册 --%>
    <form action="${pageContext.request.contextPath}/user/register" method="post">
        <table cellpadding="0" cellspacing="0" border="0" class="form_table">
            <tr>
                <td valign="middle" align="right">
                    用户名：
                </td>
                <td valign="middle" align="left">
                    <input type="text" name="username" placeholder="请输入用户名"/>
                </td>
            </tr>
            <tr>
                <td valign="middle" align="right">
                    真实姓名：
                </td>
                <td valign="middle" align="left">
                    <input type="text" name="realname" placeholder="请输入真实姓名"/>
                </td>
            </tr>
            <tr>
                <td valign="middle" align="right">
                    密码：
                </td>
                <td valign="middle" align="left">
                    <input type="password" name="password" placeholder="请输入密码"/>
                </td>
            </tr>
            <tr>
                <td valign="middle" align="right">
                    性别：
                </td>
                <td valign="middle" align="left">
                    男
                    <input type="radio" name="sex" value="男" checked="checked"/>
                    女
                    <input type="radio" name="sex" value="女"/>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" class="button" value="点击注册"/>
                    <br>
                    <br>
                    <input type="button" class="button"
                           onclick="location.href='${pageContext.request.contextPath}/login.jsp'"
                           value="有账号？去登录"/>
                </td>
            </tr>
        </table>
    </form>
</div>

<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        background-color: #f4f4f9;
    }

    #content {
        background-color: #fff;
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        width: 300px;
    }

    h1 {
        text-align: center;
        margin-bottom: 20px;
    }

    .form_table {
        width: 100%;
        border-collapse: collapse;
    }

    .form_table td {
        padding: 10px 0;
    }

    .form_table td[align="right"] {
        padding-right: 10px;
        white-space: nowrap;
    }

    .form_table td[align="left"] {
        padding-left: 10px;
    }

    input[type="text"],
    input[type="password"] {
        width: calc(100% - 20px);
        padding: 8px;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    input[type="radio"] {
        margin-right: 5px;
    }

    .button {
        width: 100%;
        padding: 10px;
        background-color: #007bff;
        color: #fff;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }

    .button:hover {
        background-color: #0056b3;
    }
</style>

</body>
</html>